<script setup lang="ts">
import { getCurrentInstance, navigateTo, redirectTo, navigateBack } from '@tarojs/taro';
import { Check as AppNutIconCheck } from '@nutui/icons-vue-taro';
/**
 * @description 当前路由信息
 */
const params = getCurrentInstance().router?.params as unknown as {
  planTaskId: string;
  assetId: string;
  /**
   * 来源: 默认巡检 inspection/maintenance/cleaning
   */
  from?: string;
  /**
   * 来源: 扫描页面scan
   */
  module?: string;
  /**
   * 2: 异常 否则正常
   */
  status?: string;
};

/**
 * 进入列表页面
 */
function jumpToListPage() {
  navigateBack();
}
</script>

<template>
  <view class="inspection-submit-success app-page--1">
    <scroll-view class="app-page__wrapper" :scroll-y="true" :lower-threshold="100">
      <view class="inspection-submit-success__header-wrapper">
        <app-nut-icon-check class="inspection-submit-success__icon" />
      </view>
      <view>任务已完成!</view>
    </scroll-view>
    <view
      class="inspection-submit-success__footer"
      v-if="params.from != 'scan' && params.status === '2'"
    >
      <nut-button
        block
        shape="round"
        type="danger"
        @click="
          navigateTo({
            url: `/pages/work-order/edit/index?planTaskId=${params.planTaskId}&assetId=${params.assetId}&from=inspection`,
          })
        "
        >故障上报</nut-button
      >
    </view>
    <view class="inspection-submit-success__footer">
      <nut-button
        block
        shape="round"
        type="info"
        @click="
          redirectTo({
            url: `/pages/inspection/edit/index?planTaskId=${params.planTaskId}&assetId=${params.assetId}`,
          })
        "
      >
        任务详情
      </nut-button>
    </view>
    <view class="inspection-submit-success__footer">
      <nut-button block shape="round" type="info" @click="jumpToListPage"> 任务列表 </nut-button>
    </view>
  </view>
</template>

<style lang="scss">
@import './index.scss';
</style>
